using GameFramework.Event;
using System;

namespace TowerDefence_Zombie
{
    public class GuideCondition_BuildTower : GuideCondition_Base
    {
        public GuideCondition_BuildTower(DRGuideCondition conditionInfo, Action conitionCompleteClick)
            : base(conditionInfo, conitionCompleteClick)
        {

        }

        public override void StartCondition()
        {
            base.StartCondition();
            GameEntry.Event.Subscribe(BuildTowerEventArgs.EventId, OnBuildTower);
        }

        private void OnBuildTower(object sender, GameEventArgs e)
        {
            BuildTowerEventArgs ne = (BuildTowerEventArgs)e;
            if (ne == null)
                return;

            IsCompleteFlag = true;
        }

        public override void Dispose()
        {
            GameEntry.Event.Unsubscribe(BuildTowerEventArgs.EventId, OnBuildTower);
            base.Dispose();
        }
    }
}
